'use strict';

const Controller = require('egg').Controller;

class SelectController extends Controller {
  async province() {
    const { ctx } = this;
    const result = await ctx.service.select.province();
    ctx.body = {
      code: 0,
      message: 'success',
      data: result,
    };
  }
  async city() {
    const { ctx } = this;
    const { province } = ctx.request.query;
    const result = await ctx.service.select.city(province);
    ctx.body = {
      code: 0,
      message: 'success',
      data: result,
    };
  }
  async state() {
    const { ctx } = this;
    const { city } = ctx.request.query;
    const result = await ctx.service.select.state(city);
    ctx.body = {
      code: 0,
      message: 'success',
      data: result,
    };
  }
}

module.exports = SelectController;
